<%@ taglib uri="/tags/struts-bean" prefix="bean" %>
<%@ taglib uri="/tags/struts-html" prefix="html" %>
<%@ taglib uri="/tags/struts-logic" prefix="logic" %>
<script type="text/javascript" src="../js/prototype.js"></script>
<script language="Javascript">
function fnSubmit()
{
	if(fnValidateMandatory() == false){
		return false;
	}
	document.levelForm.action='/createLevel.do?';
	document.levelForm.submit();
}

function fnValidateMandatory(){
	if(document.getElementById("level_name").value == ""){
		alert('Level Name is Mandatory');
		return false;
	}
	if(document.getElementById("level_positive_mark").value == ""){
		alert('Positive marks field is Mandatory');
		return false;
	}
	if(document.getElementById("level_negative_mark").value == ""){
		alert('Negative marks field is Mandatory');
		return false;
	}
	return true;
}

function fnUpdate()
{
	if(fnValidateMandatory() == false){
		return false;
	}
	document.levelForm.screen_type.value="Edit";
	document.levelForm.action='/updateLevel.do?';
	document.levelForm.submit();
}
</script>
<html:form action="/level" enctype="multipart/form-data">
	<html:hidden property="screen_type"/>
	<html:hidden property="level_id"/>
	<%String linktab = (String)request.getAttribute("selectedTab"); %>
	<table width="100%" border="0" cellspacing="0" cellpadding="0">
	  <tr>
	    <td>
	    	<table width="100%" border="0" cellspacing="0" cellpadding="0">
	  			<tr>
					<%if("CREATE".equalsIgnoreCase(linktab)) {%>
				    <td class="activeTabc1"></td>
				    <td class="activeTabbg"><div align="center" class="style10"><a href="<%=request.getAttribute("createLink")%>">Create</a></div></td>
				    <td class="activeTabc2"></td>
					<%} else {%>
					<td class="inactiveTabc1"></td>
				    <td class="inactiveTabbg"><div align="center" class="style11"><a href="<%=request.getAttribute("createLink")%>">Create</a></div></td>
				    <td class="inactiveTabc2"></td>
					<%}%>
				    <td class="spacer"></td>
					<%if("EDIT".equalsIgnoreCase(linktab)) {%>
					<td class="activeTabc1"></td>
				    <td class="activeTabbg"><div align="center" class="style10"><a href="<%=request.getAttribute("editLink")%>">Edit</a></div></td>
				    <td class="activeTabc2"></td>
					<%} else{%>
				    <td class="inactiveTabc1"></td>
				    <td class="inactiveTabbg"><div align="center" class="style11"><a href="<%=request.getAttribute("editLink")%>">Edit</a></div></td>
				    <td class="inactiveTabc2"></td>
					<%}%>
				    <td class="spacer"></td>
					<%if("VIEW".equalsIgnoreCase(linktab)) {%>
					<td class="activeTabc1"></td>
				    <td class="activeTabbg"><div align="center" class="style10"><a href="<%=request.getAttribute("viewLink")%>">View</a></div></td>
				    <td class="activeTabc2"></td>
					<%} else{%>
				    <td class="inactiveTabc1"></td>
				    <td class="inactiveTabbg"><div align="center" class="style11"><a href="<%=request.getAttribute("viewLink")%>">View</a></div></td>
				    <td class="inactiveTabc2"></td> 
					<%}%>
	  			</tr>
			</table>
		</td>
  	</tr>
  	<tr>
    	<td class="formbg" valign="top">
    		<table width="100%" border="0" cellspacing="0" cellpadding="0">
  				<tr>
    				<td>
    					<table width="100%" border="0" cellspacing="4" cellpadding="0">
							<tr>
								<td>&nbsp;</td>	
								<td>&nbsp;</td>
								<td>&nbsp;</td>
								<td>&nbsp;</td>
								<td>&nbsp;</td>
							</tr>
							<tr>
								<td colspan="5"><jsp:include page="showErrorMessage.jsp" /></td>
							</tr>
							<tr>
								<td>&nbsp;</td>
								<td class="formText">Name<font class="asterix">*</font></td>
								<td valign="middle"><html:text property="level_name" styleId="level_name" styleClass="form1" maxlength="20"/>
								</td>
								<td class="formText">Description</td>
								<td valign="middle"><html:textarea property="level_description" styleId="level_description" styleClass="textAreaForm" rows="2"/></td>
							</tr>
							<tr><td>&nbsp;</td>	
								<td class="formText">Positive Mark<font class="asterix">*</font></td>
								<td valign="middle"><html:text property="level_positive_mark" styleId="level_positive_mark" styleClass="form1" maxlength="5"/>
								<td class="formText">Negative Mark<font class="asterix">*</font></td>
								<td valign="middle"><html:text property="level_negative_mark" styleId="level_negative_mark" styleClass="form1" maxlength="5"/>
								
							</tr>
							<tr>
								<td align="left" valign="top" >&nbsp</td>
								<td class="formText">Status<font class="asterix">*</font></td>
								<td valign="middle">
									<html:select styleClass="form2" property="level_status" styleId="level_status">
										<html:option value="2">Active</html:option>
										<html:option value="3">InActive</html:option>
									</html:select>
								</td>
							</tr>
							<tr >
								<td height="100">&nbsp;</td>	
								<td colspan="4" >
								<div align="center">
					        					<logic:equal name="levelForm" property="screen_type" value="Edit">							
													<input type="button" class="imageButton" value="Update" onClick="javascript:fnUpdate()">							
												</logic:equal>
												<logic:equal name="levelForm" property="screen_type" value="">
													<input type="button" class="imageButton" value="Submit" onClick="javascript:fnSubmit()">
												</logic:equal>
					                        	</div>
								</td>
								
							</tr>
							<tr>
					    		<td width="100%" colspan="6">
					    			<table width="100%" border="0" cellspacing="0" cellpadding="0">
					      				<tr>
					        				<td class="lowerCorner1"></td>
					        				<td class="lowerbg">
					        					<div align="center">
					        					&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
					                        	</div>
					                        </td>
					        				<td class="lowerCorner2"></td>
					      				</tr>
					    			</table>
					    		</td>
					  		</tr>
						</table>
					</td>
				</tr>
			</table>
		</td>
	</tr>
</table>				
	<logic:equal name="levelForm" property="screen_type" value="View">
		<script language="JavaScript">	
			var elements = document.forms[0].elements;
			var type = "";
			for(j=0;j<elements.length;j++){
				type = elements[j].type;
				if(type == 'text' || type == 'select-one' || type == 'radio' || type == 'checkbox' || type == 'button' || type == 'textarea') {
					elements[j].disabled=true;
				}
			}
		</script>
	</logic:equal>	
</html:form>